<!DOCTYPE HTML>
<html>
<head>
	<meta charset="utf-8">
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
	<link rel="Bookmark" href="../imgs/favicon.ico"/>
	<link rel="Shortcut Icon" href="../imgs/favicon.ico"/>
	<link rel="stylesheet" type="text/css" href="../static/h-ui/css/H-ui.min.css"/>
	<link rel="stylesheet" type="text/css" href="../static/h-ui.admin/css/H-ui.admin.css"/>
	<link rel="stylesheet" type="text/css" href="../lib/Hui-iconfont/1.0.8/iconfont.css"/>
	<link rel="stylesheet" type="text/css" href="../static/h-ui.admin/skin/default/skin.css" id="skin"/>
	<link rel="stylesheet" type="text/css" href="../static/h-ui.admin/css/style.css"/>
	<title>商城</title>
</head>
<body>
<!--顶部-->
<header class="navbar-wrapper"></header>
<!--左侧菜单-->
<aside class="Hui-aside">
	<div class="menu_dropdown bk_2" id="leftMenu"></div>
</aside>

<!--首页-->
<section class="Hui-article-box">
	<nav class="breadcrumb">
		<i class="Hui-iconfont">&#xe67f;</i>
		<a href="../index.html" class="maincolor">首页</a>
		<span class="c-gray en">&gt;</span> 渠道管理
		<span class="c-gray en">&gt;</span> 参数配置
	</nav>
	<div class="Hui-article">
		<article class="cl pd-20">
			<!--<div class="cl pd-5 bg-1 bk-gray">-->
				<!--<span class="r">共有数据：<strong id="pageTotal">0</strong> 条</span>-->
			<!--</div>-->
			<div class="mt-10">
				<article class="cl pd-20">
					<form class="form form-horizontal" id="form-member-add">
						<span id="keylist"></span>
						<!--<div class="row cl">-->
							<!--<label class="form-label col-xs-4 col-sm-3">-->
								<!--<span class="c-red">*</span> 分类名称：-->
							<!--</label>-->
							<!--<div class="formControls col-xs-8 col-sm-9">-->
								<!--<input type="text" class="input-text" id="title"/>-->
							<!--</div>-->
						<!--</div>-->
						<!--<div class="row cl">-->
							<!--<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">-->
								<!--<input class="btn btn-primary radius" type="button"-->
									   <!--value="&nbsp;&nbsp; 保存配置 &nbsp;&nbsp;" onclick="modify();"/>-->
							<!--</div>-->
						<!--</div>-->
					</form>
				</article>
			</div>
		</article>
	</div>
</section>

<!--自定义弹窗-->
<span id="msgPop"></span>
</body>
</html>


<script type="text/javascript" src="../lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="../lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="../static/h-ui/js/H-ui.js"></script>
<script type="text/javascript" src="../static/h-ui.admin/js/H-ui.admin.page.js"></script>
<script type="text/javascript" src="../js/config.js"></script>
<script type="text/javascript" src="../js/view.js"></script>
<script type="text/javascript">
	(function () {
		getConfig();
	})();
	function getConfig(){
		$.ajax({
			type: apis.qdConfigList.method,
			url: apis.qdConfigList.url,
			data: {},
			success: function (res) {
				console.log(res);
				if (res.code < 0) {
					msgPop({msg: res.msg});
					return
				}
				var d = res.data;
				var h = '', i;
//				<div class="row cl">
//					<label class="form-label col-xs-4 col-sm-3">
//						<span class="c-red">*</span> 分类名称：
//					</label>
//					<div class="formControls col-xs-8 col-sm-9">
//						<input type="text" class="input-text" id="title"/>
//					</div>
//				</div>
				for (i = 0; i < d.length; i ++) {
					h += '<div class="row cl">';
					h += '<label class="form-label col-xs-4 col-sm-3">';
					h += d[i].title + '：';
					h += '</label>';
					h += '<div class="formControls col-xs-8 col-sm-9">';
					h += '<input type="text" class="input-text" id="val' + d[i].id + '" value="' + d[i].val + '" style="width: 80%;"/>';
					h += '<div style="padding: 4px 0; width: 20%; background: #0088cc; color: #eee; text-align: center; cursor: pointer; float: right;" onclick="modify(' + d[i].id + ');">保存该配置</div>';
					h += '</div>';
					h += '</div>';
				}
				$('#keylist').html(h);
			},
			error: function () {
				console.log('错误辣');
			}
		});
	}
	function modify(v){
		var val = $('#val' + v).val();
		if (!val) {
			msgPop({msg: '参数必须的'});
			return
		}
		$.ajax({
			type: apis.qdConfigModify.method,
			url: apis.qdConfigModify.url,
			data: { id: v, val: val },
			success: function (res) {
				console.log(res);
				if (res.code < 0) {
					msgPop({msg: res.msg});
					return
				}
				msgPop({msg: '修改成功'});
				setTimeout(function () {
					top.location.href = '';
				}, 1000);
			},
			error: function () {
				console.log('错误辣');
			}
		});
	}
</script>